
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamicSearchField="searchField"
      :dynamicButtons="tableButtons"
      :dynamicComponents="tableComponents"
      :dynamicApiConfig="apiConfig"
      :dynamicTableCols="tableCols"
      :dynamicFormFields="formField"
      :dynamicIsShowSelect="false"
      :dynamicIsInitTable="false"
      :dynamicIsColumnDrop="false"
      />

  </div>
</template>
<script>
import { crmApis } from "@/api/apiList/crm";
import { requestAPI } from "@/api/commonRequest";
import { oneTableWithViewTemplateMixins } from '@/components/mixins/oneTableWithViewTemplateMixins'
import OneTableTemplate from "@/components/crm/Template/crmonePage";
import Vue from "vue"

export default {
  name:"rescueInquire",
  // 组件混入对象
  mixins: [oneTableWithViewTemplateMixins],
  components: {
    OneTableTemplate
  },
  // 阻塞路由预加载网格中组件的数据
  beforeRouteEnter(to, from, next) {Vue.prototype.$ConfigCache.CacheConfig.initData(to.path, function(){next()})},
  data() {
    return {
      searchField:"搜索条件",
      // 网格查询API配置对象
      apiConfig: crmApis.csBuSaveOrderQueryFindAll,
      // 动态组件-按钮
      tableButtons: [],
      // 动态组件-查询条件
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableComponents
          : [
              {
                compKey: "compKey1",
                labelName: "服务单号",
                codeField: "serverOrder",
                component: () => import("@/components/crm/textbox/crmTextInput"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey2",
                labelName: "建单日期",
                codeField: "createdDateStart,createdDateEnd",
                component: () => import("@/components/crm/Time/crmdtDatePicker"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey3",
                labelName: "救援类型",
                codeField: "smallTypeCode",
                component: () => import("@/components/crm/crmEjectWindows/crmServiceTypeJY/index"),
                type: "propus",
                isMust: false,
                isMul:false,
              },
              {
                compKey: "compKey4",
                labelName: "单据状态",
                codeField: "status",
                lookuptype: "LX006",
                remark: "1",
                component: () => import("@/components/crm/lookupValue/lookupvalue"),
                type: "dropdownList",
                isMust: false,
                isMul:false,
              },
              {
                compKey: "compKey5",
                labelName: "客户名称",
                codeField: "custName",
                component: () => import("@/components/crm/textbox/crmTextInput"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey6",
                labelName: "车牌号",
                codeField: "rescueCarLicenseNumber",
                component: () => import("@/components/crm/textbox/crmTextInput"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey7",
                labelName: "电话",
                codeField: "contactTel",
                component: () => import("@/components/crm/textbox/crmTextInput"),
                type: "inputText",
                isMust: false
              },
              {
                compKey: "compKey8",
                labelName: "责任网点",
                codeField: "dutyOrgCode",
                component: () => import("@/components/crm/crmEjectWindows/crmChangeDlr/index"),
                type: "propus",
                isMust: false,
                isMul:false,
              },
              // {
              //   compKey: "compKey9",
              //   labelName: "派单方式",
              //   codeField: "",
              //   lookuptype: "LX839",
              //   component: () => import("@/components/crm/lookupValue/lookupvalue"),
              //   type: "dropdownList",
              //   isMust: false,
              //   isMul:false,
              // },
              {
                compKey: "compKey10",
                labelName: "解决方式",
                codeField: "resolveMethod",
                lookuptype: "LX005",
                component: () => import("@/components/crm/lookupValue/lookupvalue"),
                type: "dropdownList",
                isMust: false,
                isMul:false,
              },
              {
                compKey: "compKey11",
                labelName: "建单人",
                codeField: "billEmpName",
                component: () => import("@/components/crm/textbox/crmTextInput"),
                type: "inputText",
                isMust: false
              }
            ],
      // 动态生成网格列
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
            {
          prop: "controlBtn",
          label: "操作",
          codeField: "controlBtn",
          width: 55,
          align: "center",
          fixed: true,
          isComponent: true,
          comps: [
            {
              compKey: "propKey2",
              labelName: "追加",
              // codeField: "editControlBtn",
              clickEvent: this.JyAdd,
              component: () => import("@/components/org/linkButton")
            },
          ]
        },
              {
                prop: "serverOrder",
                label: "服务单号",
                width: 120,
                align: "center",
                isComponent: true,
                fixed:true,
                comps: [
                  {
                    compKey: "propKey0",
                    codeField: "serverOrder",
                    align: "center",
                    isShowLabel: true,
                    isShow: true,
                    clickEvent: this.Jydetail,
                    component: () => import("@/components/org/linkButton")
                  }
                ]
              },
              {
                prop: "createdDate",
                label: "建单日期",
                width: 180,
                fixed:true,
                align: "center"
              },
              {
                prop: "serverFullClassName",
                label: "救援类型",
                width: 180,
                fixed:true,
                align: "center"
              },
              {
                prop: "statusName",
                label: "单据状态",
                width: 120,
                align: "center"
              },
              {
                prop: "custName",
                label: "客户名称",
                width: 120,
                align: "center",
              },
              {
                prop: "rescueCarLicenseNumber",
                label: "车牌号",
                width: 100,
                align: "center"
              },
              {
                prop: "contactTel",
                label: "电话",
                width: 120,
                align: "center"
              },
              {
                prop: "dutyOrgName",
                label: "责任网点",
                width: 130,
                align: "center"
              },
              // {
              //   prop: "",
              //   label: "派单方式",
              //   width: 100,
              //   align: "center"
              // },
              {
                prop: "resolveMethodName",
                label: "解决方式",
                width: 80,
                align: "center",
              },
              {
                prop: "empName",
                label: "建单人",
                width: 100,
                align: "center"
              }
            ],
      // 表单查询数据--重置查询条件
      formField: {
        oemCode:"1",
        groupCode: "1",
        serverOrder:"",
        createdDateStart:"",
        createdDateEnd:"",
        status:"",
        smallTypeCode:"",
        custName:"",
        contactTel:"",
        rescueCarLicenseNumber:"",
        resolveMethod:"",
        dutyOrgCode:"",
        billEmpName:"",
        //派单方式
      },
      custName:"",
      custClassCode:"",
      phone:"",
    };
  },
  methods: {
    JyAdd(index) {
      var curIndex = index;
      const that = this.$refs.multipleTable;
      if (curIndex === undefined || curIndex === null) {
        var currentRow;
        if (that.isMul === true) {
          // 多选
          var selectData = that.selection;
          if (selectData.length > 0) {
            currentRow = selectData[0];
          }
        } else {
          // 单选
          currentRow = that.currentRow;
        }
        if (currentRow) {
          curIndex = currentRow.index;
        }
      }

      if (curIndex === undefined || curIndex === null) {
        this.$alert("请选择需要追加的数据", "提示");
        return;
      }
      that.list[curIndex]["hZZ"]=this;
      this.$crmcf.jumpDetailTag(this,'addRescueOrder','/addRescueOrder',that.list[curIndex])
    },
    Jydetail(index) {
      var curIndex = index;
      const that = this.$refs.multipleTable;
      if (curIndex === undefined || curIndex === null) {
        var currentRow;
        if (that.isMul === true) {
          // 多选
          var selectData = that.selection;
          if (selectData.length > 0) {
            currentRow = selectData[0];
          }
        } else {
          // 单选
          currentRow = that.currentRow;
        }
        if (currentRow) {
          curIndex = currentRow.index;
        }
      }

      if (curIndex === undefined || curIndex === null) {
        this.$alert("请选择需要查看的数据", "提示");
        return;
      }
      this.$crmcf.jumpDetailTag(this,'rescueDetail','/rescueDetail',that.list[curIndex])
    },
  }
};
</script>
